﻿Imports ACompany.OrderProcessing.Presentation

Partial Class OrderList
    Inherits System.Web.UI.Page
    Implements IOrderListView

    Private _Presenter As OrderListPresenter

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        _Presenter = New OrderListPresenter(Me)
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            _Presenter.Display()
        End If
    End Sub

    Public WriteOnly Property Orders() As System.Collections.Generic.List(Of ACompany.OrderProcessing.Model.Order) Implements ACompany.OrderProcessing.Presentation.IOrderListView.Orders
        Set(ByVal value As System.Collections.Generic.List(Of ACompany.OrderProcessing.Model.Order))
            Me.grdOrders.DataSource = value
            Me.grdOrders.DataBind()
        End Set
    End Property

    Public ReadOnly Property OrderStatus() As ACompany.OrderProcessing.Model.OrderStatus Implements ACompany.OrderProcessing.Presentation.IOrderListView.OrderStatus
        Get
            Return Me.ddlOrderStatus.SelectedValue
        End Get
    End Property

    Protected Sub ddlOrderStatus_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlOrderStatus.SelectedIndexChanged
        _Presenter.Display()
    End Sub

    Public Sub ErrorMessage(ByVal Message As String) Implements ACompany.OrderProcessing.Presentation.IBaseView.ErrorMessage
        If String.IsNullOrEmpty(Message) Then
            pnlError.Visible = False
        Else
            pnlError.Visible = True
        End If
        Me.litErrorMessage.Text = Replace(Message, Environment.NewLine, "<br/>")
    End Sub

    Public Sub InfoMessage(ByVal Message As String) Implements ACompany.OrderProcessing.Presentation.IBaseView.InfoMessage
        If String.IsNullOrEmpty(Message) Then
            pnlInfo.Visible = False
        Else
            pnlInfo.Visible = True
        End If
        Me.litInfoMessage.Text = Replace(Message, Environment.NewLine, "<br/>")
    End Sub

    Public Sub ViewTitle(ByVal title As String) Implements ACompany.OrderProcessing.Presentation.IBaseView.ViewTitle

    End Sub

End Class
